layui.use(['common'], function (common) {
    var $ = layui.$, form = layui.form, admin = layui.admin
    layui.data.done = function (d) {
        var data = d.data

        let editorId = 'editor';
        common.editor(editorId);
        if (data.value) {
            setTimeout(() => {
                var html = data.value
                 tinymce.activeEditor.setContent(html);
            }, 800)
        }
        form.render()

        form.on(`submit(LAY-home-footer-listform-submit)`, function (data) {
            var field = data.field;
            field.value = tinymce.activeEditor.getContent()
            let postData = [{
                id: field.id, value: field.value,
            }]
            admin.req({
                url: window.globalConfig.url_config + "/1?access_token=" + layui.data('layuiAdmin').access_token,
                type: "PUT",
                data: {
                    data: postData
                },
                success: function (res) {
                    common.ctmMsg(res.code, res.msg)
                    location.hash = `/home/page/list`
                }
            })
        })
    }

})